import request from '@/service'
/** 用户的网络请求 */
// 获取所有社团
export function getAllClubs(limit: number, offset: number, status?: string) {
  return request.get({
    url: '/clubs',
    params: {
      limit,
      offset,
      status
    }
  })
}

// 创建社团
export function postCreateClub(clubInfo: any) {
  return request.post({
    url: '/clubs',
    data: clubInfo
  })
}

// 查询单个社团
export function getClubById(id: number) {
  return request.get({
    url: `/clubs/${id}`
  })
}

// 根社团名字模糊查询社团
export function getClubByName(
  name: string,
  limit: number,
  offset: number,
  status?: string
) {
  return request.get({
    url: '/clubs/clubname',
    params: {
      name,
      limit,
      offset,
      status
    }
  })
}

// 删除一个社团
export function deleteClubById(id: number) {
  return request.delete({
    url: `/clubs/${id}`
  })
}

//更新社团
export function updateClub(id: number, clubInfo: any) {
  return request.put({
    url: `/clubs/${id}`,
    data: clubInfo
  })
}

// 修改社团状态
export function updateClubStatus(id: number, status: string) {
  return request.put({
    url: `/clubs/${id}/status`,
    params: {
      status
    }
  })
}

// 获取单个社团的成员
export function getClubMemberByClubId(
  id: number,
  limit?: number,
  offset?: number,
  name?: string,
  status?: string
) {
  return request.get({
    url: `/clubs/${id}/members`,
    params: {
      limit,
      offset,
      name,
      status
    }
  })
}

// 更改成员状态为active
export function reviewMemberById(club_id: number, id: number, status?: string) {
  return request.put({
    url: `clubs/${club_id}/members/${id}/review`,
    data: {
      status
    }
  })
}

// 修改社团成员状态
export function deleteMemberById(user_id: number, club_id: number) {
  return request.delete({
    url: `/clubs/${club_id}/members/${user_id}/remove`
  })
}

// 根据id1获取社团
export function getClubByUserId() {
  return request.get({
    url: `/clubs/leader/club`
  })
}

// 查询参加人数
export function joinData() {
  return request.get({
    url: '/clubs/join/count'
  })
}
